;(function($){
	$.d = {
		/**
		 * 消息框队列
		 */
		messageQueue : [],
		messageTemplate : $('<div class="alert alert-dismissible"><button type="button" class="close">&times;</button></div>'),
		
		/**
		 * 显示消息
		 * @param {String} msg 消息内容
		 * @param {Number} timeout 自动消失毫秒 默认 5000
		 * @param {String} level 消息等级 success info(默认) warning danger
		 */
		m : function(msg,timeout,level){
			var current = this;
			timeout=timeout||5000;
			level=level||"info";
			var div = this.messageTemplate.clone();
			div.addClass("alert-"+level)
				.append(msg)
				.appendTo($("body"));
			var height = div.outerHeight();
			div.addClass("animated bounceInUp");
			$.each(current.messageQueue, function(i,v) {
				v.data("b",v.data("b")+height+5);
				v.stop();
				v.animate({
					bottom:v.data("b")
				},1000);
			});
			window.setTimeout(function(){
				div.removeClass("animated bounceInUp");
			},1000);
			div.css({
					position: "fixed",
					"z-index":99999,
					right: 0,
					bottom: 0,
					margin:"5px"
			}).data("b",0);
			this.messageQueue.push(div);
			
			var timer = null;
			/**
			 * 移除消息
			 * @param {Object} div
			 */
			var removeMessage = function(div){
				if(timer!=null){
					window.clearTimeout(timer);
				}
				var index = current.messageQueue.indexOf(div);
				if(index>-1){
					var height = div.outerHeight();
					for(var i=0;i<index;i++){
						var v = current.messageQueue[i];
						v.data("b",v.data("b")-height-5);
						v.stop();
						v.animate({
							bottom:v.data("b")
						},1000);
					}
					current.messageQueue.splice(index,1);
					div.addClass("animated bounceOutDown");
					window.setTimeout(function(){
						div.remove();
					},1000);
				}
			}
			
			
			
			div.children(".close").click(function(){
				removeMessage(div);
			});
			timer = window.setTimeout(function(){
				removeMessage(div);
			},timeout+1000);
			
			
		},
		/**
		 * 成功消息
		 * @param {String} msg
		 * @param {Number} timeout
		 */
		s : function(msg,timeout){
			this.m(msg,timeout,"success");
		},
		/**
		 * 一般消息
		 * @param {String} msg
		 * @param {Number} timeout
		 */
		i : function(msg,timeout){
			this.m(msg,timeout,"info");
		},
		
		/**
		 * 警告消息
		 * @param {String} msg
		 * @param {Number} timeout
		 */
		w : function(msg,timeout){
			this.m(msg,timeout,"warning");
		},
		
		/**
		 * 错误消息
		 * @param {String} msg
		 * @param {Number} timeout
		 */
		e : function(msg,timeout){
			this.m(msg,timeout,"danger");
		}
		
	}
	BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DEFAULT] = '系统提示信息';
    BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_INFO] = '系统提示信息';
    BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_PRIMARY] = '系统提示信息';
    BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_SUCCESS] = '系统成功提示';
    BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_WARNING] = '系统警告信息';
    BootstrapDialog.DEFAULT_TEXTS[BootstrapDialog.TYPE_DANGER] = '系统错误信息';
    BootstrapDialog.DEFAULT_TEXTS['OK'] = '确定';
    BootstrapDialog.DEFAULT_TEXTS['CANCEL'] = '取消';
    BootstrapDialog.DEFAULT_TEXTS['CONFIRM'] = '确认';
	$.extend($.d,BootstrapDialog);
	$.d.a = $.d.alert;
	$.d.c = $.d.confirm;

})(jQuery);